//
//  YYEHotClassifiCollectionViewCell.m
//  YuYingEDU
//
//  Created by 胡波 on 2017/12/28.
//  Copyright © 2017年 胡波. All rights reserved.
//

#import "YYEHotClassifiCollectionViewCell.h"

@interface YYEHotClassifiCollectionViewCell ()

@property (nonatomic,strong) UIImageView *backIV;
@property (nonatomic,strong) UIImageView *classifyIV;
@property (nonatomic,strong) UILabel *classifyLabel;
@property (nonatomic,strong) UILabel *courseLabel;

@end

@implementation YYEHotClassifiCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
    
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        self.backIV = [[UIImageView alloc]init];
        [self.contentView addSubview:self.backIV];
        
        self.classifyIV = [[UIImageView alloc]init];
        [self.backIV addSubview:self.classifyIV];
        
        self.classifyLabel = [[UILabel alloc]init];
        self.classifyLabel.textColor = [UIColor blackColor];
        self.classifyLabel.font = [UIFont systemFontOfSize:12];
        self.classifyLabel.textAlignment = NSTextAlignmentCenter;
        [self.backIV addSubview:self.classifyLabel];
        
        self.courseLabel = [[UILabel alloc]init];
        self.courseLabel.textColor = [UIColor blackColor];
        self.courseLabel.font = [UIFont systemFontOfSize:11];
        self.courseLabel.textAlignment = NSTextAlignmentCenter;
        [self.backIV addSubview:self.courseLabel];
        
        self.backIV.image = [UIImage imageNamed:@"whiteBG"];
//        self.classifyIV.backgroundColor = [UIColor redColor];
        self.classifyLabel.text = @"计算机网络";
        self.courseLabel.text = @"ios开发";
        
    }
    return self;
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.backIV makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView).offset(UIEdgeInsetsMake(0, 3, 0, 3));
    }];
    
    [self.classifyIV makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.backIV.top).offset(6);
        make.centerX.equalTo(self.backIV.centerX);
        make.size.equalTo(CGSizeMake(40, 40));
    }];
    
    [self.classifyLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.backIV);
        make.top.equalTo(self.classifyIV.bottom).offset(6);
    }];
    
    [self.courseLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.backIV);
        make.top.equalTo(self.classifyLabel.bottom);
    }];
    
}

- (void)setModel:(YYECourseClassifyModel *)model {
    _model = model;
    
    [self.classifyIV sd_setImageWithURL:[NSURL URLWithString:model.button_img] placeholderImage:[UIImage imageNamed:@"classifyHolder"]];
    self.classifyLabel.text = model.pname;
    self.courseLabel.text = model.name;
    
}

@end
